<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/3/24
 * Time: 11:46
 */

namespace app\home\model;

use app\common\model\User;
use think\Model;
use traits\model\SoftDelete;

class Versions extends Model
{
    use SoftDelete;

    protected $createTime = 'ctime';
    protected $updateTime = '';
    protected $deleteTime = 'deleted';
    // 自动写入时间戳
    protected $autoWriteTimestamp = true;

    public function block()
    {
        return $this->belongsToMany('Block','VersionsBlock','block_id','versions_id');
    }

    public static function getStatusAttr($value){
        return $value == 1 ? true : false ;
    }

    public static function getCreatorAttr($id){
        return $id ? User::where('id',$id)->value('nick') : '';
    }
}